<a href="#" class="btn btn-add"><i class="icon-plus"></i> Novo grupo</a>
<br />
<br />


<div class="accordion" id="myAccordion">
  <?php $i = 0;
  foreach ($grupos as $g) { ?>
    <div class="accordion-group">
      <div class="accordion-heading stripes">
        <a class="accordion-toggle" data-toggle="collapse" data-parent="#myAccordion" href="#<?php echo $g->nome ?>">
          <?php echo $g->nome ?> <small><?php echo $g->descricao ?></small>
        </a>
      </div>
      <div id="<?php echo $g->nome ?>" class="accordion-body collapse">
        <div class="accordion-inner">
          <table class="list">
            <colgroup>
              <col width="30%" />
              <col width="15%" />
              <col width="15%" />
              <col width="15%" />
              <col width="15%" />
            </colgroup>

            <thead>
              <tr>
                <th>Módulo</th>
                <th>Visualizar</th>
                <th>Adicionar</th>
                <th>Editar</th>
                <th>Excluir</th>
              </tr>
            </thead>

            <tbody>
              <?php foreach ($modulos as $m) { ?>
                <tr>
                  <td><?php echo $m->nome ?></td>
                  <td><input id="visualizar-<?php echo md5("MB{$m->id}SG") ?>" class="icheckbox_flat-grey" type="checkbox" <?php echo $permissoes[$i]->visualizar ? "checked" : "" ?> <?php echo ($g->nome == "Administradores") ? "disabled" : "" ?> /></td>
                  <td><input id="adicionar-<?php echo md5("MB{$m->id}SG") ?>" class="icheckbox_flat-grey" type="checkbox" <?php echo $permissoes[$i]->adicionar ? "checked" : "" ?> <?php echo ($g->nome == "Administradores") ? "disabled" : "" ?> /></td>
                  <td><input id="editar-<?php echo md5("MB{$m->id}SG") ?>" class="icheckbox_flat-grey" type="checkbox" <?php echo $permissoes[$i]->editar ? "checked" : "" ?> <?php echo ($g->nome == "Administradores") ? "disabled" : "" ?> /></td>
                  <td><input id="excluir-<?php echo md5("MB{$m->id}SG") ?>" class="icheckbox_flat-grey" type="checkbox" <?php echo $permissoes[$i]->excluir ? "checked" : "" ?> <?php echo ($g->nome == "Administradores") ? "disabled" : "" ?> /></td>
                </tr>
                <?php $i++;
              } ?>
            </tbody>
          </table>

          <?php if ($g->nome != "Administradores") { ?>
            <div class="form-actions">
              <button id="salvar-<?php echo md5("MB{$g->id}SG") ?>" class="btn pull-right" type="button">Salvar</button>
            </div>
          <?php } ?>
        </div>
      </div>
    </div>
  <?php } ?>
</div>